<!--
 * 考试答题界面组件
 * 
 * 功能说明：
 * 1. 提供完整的考试答题界面
 * 2. 支持选择题、填空题、判断题三种题型
 * 3. 集成摄像头监控功能，防止作弊
 * 4. 实时倒计时显示
 * 5. 题目导航和答题状态显示
 * 6. 练习模式和正式考试模式
 * 
 * 后端交互：
 * - GET /api/exam/getExamInfo：获取考试信息
 * - POST /api/exam/getExamById：根据ID获取考试详情
 * - POST /api/exam/submitExam：提交考试答案
 * 
 * 摄像头功能：
 * - 使用face-api.js进行人脸检测
 * - 实时监控学生是否面对摄像头
 * - 检测不到人脸时显示警告
 * 

-->
<template>
  <div id="answer">
    <!-- 摄像头监控区域 - 只在正式考试时显示 -->
    <div class="camera-container" v-show="!isPractice">
      <!-- 视频元素：显示摄像头画面 -->
      <video id="video" autoplay muted></video>
      <!-- 画布元素：用于人脸检测和绘制检测框 -->
      <canvas class="camera-canvas" id="canvas"></canvas>
      
      <!-- 摄像头状态显示 -->
      <div class="camera-status" v-show="isCameraActive">
        <!-- 人脸检测状态：检测到人脸显示绿色勾，否则显示警告 -->
        <span v-if="faceDetected" class="status-ok">✓ 检测到人脸</span>
        <span v-else class="status-warning">✓ 检测到人脸</span>
        <!-- 重新检测按钮 -->
        <button class="camera-restart-btn" @click="restartFaceDetection" title="重新启动摄像头">
          <i class="iconfont icon-refresh"></i>
        </button>
      </div>
      
      <!-- 摄像头占位内容：摄像头未启动时显示 -->
      <div class="camera-placeholder-content" v-show="!isCameraActive">
        <i class="iconfont icon-camera"></i>
        <p>摄像头监控</p>
        <p class="camera-placeholder-desc" v-if="cameraInitializing">正在启动摄像头...</p>
        <p class="camera-placeholder-desc" v-else>点击启动摄像头监控</p>
        <!-- 启动摄像头按钮 -->
        <button class="camera-init-btn" @click="initCamera" v-if="!cameraInitializing" :disabled="cameraInitializing">
          {{ cameraInitializing ? '启动中...' : '启动摄像头' }}
        </button>
      </div>
    </div>
    
    <!-- 顶部信息栏 -->
    <div class="top">
      <ul class="item">
        <!-- 左侧菜单切换按钮 -->
        <li>
          <i
            class="iconfont icon-menufold icon20"
            ref="toggle"
            @click="slider_flag = !slider_flag"
          ></i>
        </li>
        <!-- 考试信息显示 -->
        <li>{{ examData.type }}-{{ examData.source }}</li>
        <!-- 用户信息下拉菜单 -->
        <li @click="flag = !flag" style="cursor:pointer;">
          <i class="iconfont icon-user icon20"></i>
          <div class="msg" v-if="flag" @click="flag = !flag">
            <p>姓名：{{ userInfo.name }}</p>
            <p>准考证号: {{ userInfo.id }}</p>
          </div>
        </li>
        <!-- 返回按钮 -->
        <li><i class="iconfont icon-arrLeft icon20"></i></li>
      </ul>
    </div>
    
    <!-- 主要内容区域 -->
    <div class="flexarea">
      <!-- 左边题目编号区 - 可折叠 -->
      <transition name="slider-fade">
        <div class="left" v-if="slider_flag">
          <!-- 题目状态图例 -->
          <ul class="l-top">
            <li>
              <a href="javascript:;"></a>
              <span>当前</span>
            </li>
            <li>
              <a href="javascript:;"></a>
              <span>未答</span>
            </li>
            <li>
              <a href="javascript:;"></a>
              <span>已答</span>
            </li>
            <li>
              <a href="javascript:;"></a>
              <span>标记</span>
            </li>
          </ul>
          
          <!-- 题目编号列表 -->
          <div class="l-bottom">
            <!-- 选择题部分 -->
            <div class="item">
              <p>选择题部分</p>
              <ul>
                <li v-for="(list, index1) in topic[1]" :key="index1">
                  <a
                    href="javascript:;"
                    @click="change(index1)"
                    :class="{
                      border: index == index1 && currentType == 1, // 当前题目高亮
                      bg: bg_flag && topic[1][index1].isClick == true, // 已答题高亮
                    }"
                  >
                    <!-- 标记图标 -->
                    <span
                      :class="{ mark: topic[1][index1].isMark == true }"
                    ></span>
                    {{ index1 + 1 }}
                  </a>
                </li>
              </ul>
            </div>
            
            <!-- 填空题部分 -->
            <div class="item">
              <p>填空题部分</p>
              <ul>
                <li v-for="(list, index2) in topic[2]" :key="index2">
                  <a
                    href="javascript:;"
                    @click="fill(index2)"
                    :class="{
                      border: index == index2 && currentType == 2,
                      bg: fillAnswer[index2][3] == true, // 填空题已答状态
                    }"
                    ><span
                      :class="{ mark: topic[2][index2].isMark == true }"
                    ></span
                    >{{ topicCount[0] + index2 + 1 }}</a
                  >
                </li>
              </ul>
            </div>
            
            <!-- 判断题部分 -->
            <div class="item">
              <p>判断题部分</p>
              <ul>
                <li v-for="(list, index3) in topic[3]" :key="index3">
                  <a
                    href="javascript:;"
                    @click="judge(index3)"
                    :class="{
                      border: index == index3 && currentType == 3,
                      bg: bg_flag && topic[3][index3].isClick == true,
                    }"
                    ><span
                      :class="{ mark: topic[3][index3].isMark == true }"
                    ></span
                    >{{ topicCount[0] + topicCount[1] + index3 + 1 }}</a
                  >
                </li>
              </ul>
            </div>
            
            <!-- 结束考试按钮 -->
            <div class="final" @click="finishExam()">结束考试</div>
          </div>
        </div>
      </transition>
      
      <!-- 右边选择答题区 -->
      <transition name="slider-fade">
        <div class="right">
          <!-- 题目标题和倒计时 -->
          <div class="title">
            <p>{{ title }}</p>
            <i class="iconfont icon-right auto-right"></i>
            <span
              >全卷共{{ topicCount[0] + topicCount[1] + topicCount[2] }}题
              <!-- 倒计时只在正式考试时显示 -->
              <span v-if="!isPractice">
                <i class="iconfont icon-time"></i>倒计时：<b>{{ time }}</b
                >分钟</span
              >
            </span>
          </div>
          
          <!-- 题目内容区域 -->
          <div class="content">
            <!-- 题目文本 -->
            <p class="topic">
              <span class="number">{{ number }}</span
              >{{ showQuestion }}
            </p>
            
            <!-- 选择题答题区域 -->
            <div v-if="currentType == 1">
              <!-- 单选按钮组 -->
              <el-radio-group v-model="radio[index]" @change="getChangeLabel">
                <el-radio :label="1">{{ showAnswer.answerA }}</el-radio>
                <el-radio :label="2">{{ showAnswer.answerB }}</el-radio>
                <el-radio :label="3">{{ showAnswer.answerC }}</el-radio>
                <el-radio :label="4">{{ showAnswer.answerD }}</el-radio>
              </el-radio-group>
              
              <!-- 练习模式下的答案解析 -->
              <div class="analysis" v-if="isPractice&&radio[index]!=undefined">
                <ul>
                  <li>
                    <el-tag type="success">正确答案：</el-tag
                    ><span class="right">{{ reduceAnswer.rightAnswer }}</span>
                  </li>
                  <li><el-tag>题目解析：</el-tag></li>
                  <li>
                    {{
                      reduceAnswer.analysis == null
                        ? "暂无解析"
                        : reduceAnswer.analysis
                    }}
                  </li>
                </ul>
              </div>
            </div>
            
            <!-- 填空题答题区域 -->
            <div class="fill" v-if="currentType == 2">
              <!-- 填空题输入框 -->
              <div v-for="(item, currentIndex) in part" :key="currentIndex">
                <el-input
                  placeholder="请填在此处"
                  v-model="fillAnswer[index][currentIndex]"
                  clearable
                  @blur="fillBG"
                >
                </el-input>
              </div>
              
              <!-- 练习模式下的答案解析 -->
              <div class="analysis" v-if="isPractice&&fillAnswer[index][0]!=undefined">
                <ul>
                  <li>
                    <el-tag type="success">正确答案：</el-tag
                    ><span class="right">{{ topic[2][index].answer }}</span>
                  </li>
                  <li><el-tag>题目解析：</el-tag></li>
                  <li>
                    {{
                      topic[2][index].analysis == null
                        ? "暂无解析"
                        : topic[2][index].analysis
                    }}
                  </li>
                </ul>
              </div>
            </div>
            
            <!-- 判断题答题区域 -->
            <div v-if="currentType == 3">
              <!-- 判断题单选按钮 -->
              <el-radio-group v-model="judgeAnswer[index]" @change="getJudgeLabel">
                <el-radio :label="1">正确</el-radio>
                <el-radio :label="2">错误</el-radio>
              </el-radio-group>
              
              <!-- 练习模式下的答案解析 -->
              <div class="analysis" v-if="isPractice&&judgeAnswer[index]!=undefined">
                <ul>
                  <li>
                    <el-tag type="success">正确答案：</el-tag
                    ><span class="right">{{ topic[3][index].answer }}</span>
                  </li>
                  <li><el-tag>题目解析：</el-tag></li>
                  <li>
                    {{
                      topic[3][index].analysis == null
                        ? "暂无解析"
                        : topic[3][index].analysis
                    }}
                  </li>
                </ul>
              </div>
            </div>
          </div>
          
          <!-- 底部操作按钮 -->
          <div class="footer">
            <div class="left">
              <!-- 上一题按钮 -->
              <el-button @click="previous()" :disabled="index == 0">上一题</el-button>
              <!-- 下一题按钮 -->
              <el-button @click="next()" :disabled="index == topicCount[0] + topicCount[1] + topicCount[2] - 1">下一题</el-button>
            </div>
            <div class="right">
              <!-- 标记题目按钮 -->
              <el-button @click="markQuestion()">标记题目</el-button>
              <!-- 提交答案按钮 -->
              <el-button type="primary" @click="submitAnswer()">提交答案</el-button>
            </div>
          </div>
        </div>
      </transition>
    </div>
  </div>
</template>

<script>
/*
 * 考试答题组件的JavaScript逻辑
 * 
 * 主要功能：
 * 1. 题目数据管理和状态控制
 * 2. 答题逻辑处理
 * 3. 摄像头监控功能
 * 4. 倒计时功能
 * 5. 与后端API交互
 */

export default {
  name: "answer", // 组件名称
  data() {
    return {
      // 考试相关数据
      examData: {}, // 考试基本信息
      topic: {}, // 题目数据
      topicCount: [], // 各类型题目数量
      currentType: 1, // 当前题目类型（1:选择题 2:填空题 3:判断题）
      index: 0, // 当前题目索引
      title: '', // 当前题目类型标题
      number: '', // 当前题目编号
      showQuestion: '', // 当前题目内容
      showAnswer: {}, // 当前题目选项
      reduceAnswer: {}, // 当前题目答案
      
      // 答题数据
      radio: [], // 选择题答案
      fillAnswer: [], // 填空题答案
      judgeAnswer: [], // 判断题答案
      
      // 界面状态
      slider_flag: true, // 左侧题目导航显示状态
      flag: false, // 用户信息下拉菜单状态
      bg_flag: false, // 答题状态标志
      isPractice: false, // 是否为练习模式
      
      // 用户信息
      userInfo: {
        name: '',
        id: ''
      },
      
      // 倒计时相关
      time: 0, // 剩余时间（分钟）
      timer: null, // 倒计时定时器
      
      // 摄像头监控相关
      isCameraActive: false, // 摄像头是否激活
      cameraInitializing: false, // 摄像头是否正在初始化
      faceDetected: false, // 是否检测到人脸
      faceDetectionTimer: null, // 人脸检测定时器
      videoStream: null, // 视频流
      
      // 人脸检测相关
      faceDetectionInterval: null, // 人脸检测间隔定时器
      noFaceCount: 0, // 连续未检测到人脸的次数
      maxNoFaceCount: 10, // 最大连续未检测到人脸的次数
    }
  },
  
  methods: {
    // ==================== 摄像头监控相关方法 ====================
    
    /**
     * 初始化摄像头
     * 请求用户摄像头权限并启动视频流
     */
    async initCamera() {
      try {
        this.cameraInitializing = true;
        
        // 请求摄像头权限
        const stream = await navigator.mediaDevices.getUserMedia({ 
          video: true 
        });
        
        this.videoStream = stream;
        const video = document.getElementById('video');
        video.srcObject = stream;
        
        // 等待视频元数据加载完成
        await new Promise((resolve) => {
          video.onloadedmetadata = () => {
            video.play();
            resolve();
          };
        });
        
        this.isCameraActive = true;
        this.cameraInitializing = false;
        
        // 启动人脸检测
        this.startFaceDetection();
        
      } catch (error) {
        console.error('摄像头启动失败:', error);
        this.$message.error('摄像头启动失败，请检查权限设置');
        this.cameraInitializing = false;
      }
    },
    
    /**
     * 启动人脸检测
     * 使用face-api.js进行实时人脸检测
     */
    async startFaceDetection() {
      if (!this.isCameraActive) return;
      
      // 加载人脸检测模型
      await faceapi.loadTinyFaceDetectorModel('/models');
      await faceapi.loadFaceLandmarkTinyModel('/models');
      
      const video = document.getElementById('video');
      const canvas = document.getElementById('canvas');
      
      // 设置画布尺寸
      canvas.width = video.videoWidth;
      canvas.height = video.videoHeight;
      
      // 开始定期检测人脸
      this.faceDetectionInterval = setInterval(async () => {
        if (!this.isCameraActive) return;
        
        try {
          // 检测人脸
          const detections = await faceapi.detectAllFaces(video, new faceapi.TinyFaceDetectorOptions())
            .withFaceLandmarks(true);
          
          // 清空画布
          const ctx = canvas.getContext('2d');
          ctx.clearRect(0, 0, canvas.width, canvas.height);
          
          if (detections.length > 0) {
            // 检测到人脸
            this.faceDetected = true;
            this.noFaceCount = 0;
            
            // 在画布上绘制检测框
            faceapi.draw.drawDetections(canvas, detections);
            faceapi.draw.drawFaceLandmarks(canvas, detections);
            
          } else {
            // 未检测到人脸
            this.faceDetected = false;
            this.noFaceCount++;
            
            // 连续多次未检测到人脸时显示警告
            if (this.noFaceCount >= this.maxNoFaceCount) {
              this.showFaceWarning();
            }
          }
        } catch (error) {
          console.error('人脸检测错误:', error);
        }
      }, 1000); // 每秒检测一次
    },
    
    /**
     * 重新启动人脸检测
     * 不停止摄像头，只重新启动检测逻辑
     */
    restartFaceDetection() {
      if (this.faceDetectionInterval) {
        clearInterval(this.faceDetectionInterval);
      }
      this.startFaceDetection();
    },
    
    /**
     * 显示人脸检测警告
     */
    showFaceWarning() {
      this.$message({
        message: '警告：未检测到人脸，请确保面对摄像头！',
        type: 'warning',
        duration: 3000
      });
    },
    
    /**
     * 停止摄像头
     */
    stopCamera() {
      if (this.videoStream) {
        this.videoStream.getTracks().forEach(track => track.stop());
        this.videoStream = null;
      }
      
      if (this.faceDetectionInterval) {
        clearInterval(this.faceDetectionInterval);
        this.faceDetectionInterval = null;
      }
      
      this.isCameraActive = false;
      this.faceDetected = false;
    },
    
    // ==================== 考试相关方法 ====================
    
    /**
     * 获取考试信息
     * 从后端API获取考试详情和题目
     */
    getExamInfo() {
      // 从URL参数获取考试ID
      const examId = this.$route.query.examId;
      
      this.$axios({
        url: `/api/exam/getExamById`,
        method: 'post',
        data: {
          examId: examId
        }
      }).then(res => {
        const data = res.data.data;
        this.examData = data;
        this.topic = data.questions;
        this.topicCount = [
          data.questions[1].length, // 选择题数量
          data.questions[2].length, // 填空题数量
          data.questions[3].length  // 判断题数量
        ];
        
        // 初始化答题数据
        this.initAnswerData();
        
        // 显示第一题
        this.showQuestion();
        
        // 启动倒计时（正式考试模式）
        if (!this.isPractice) {
          this.startTimer();
        }
      });
    },
    
    /**
     * 初始化答题数据
     */
    initAnswerData() {
      // 初始化选择题答案数组
      this.radio = new Array(this.topicCount[0]).fill(undefined);
      
      // 初始化填空题答案数组
      this.fillAnswer = [];
      for (let i = 0; i < this.topicCount[1]; i++) {
        this.fillAnswer[i] = new Array(4).fill(''); // 假设每道填空题最多4个空
      }
      
      // 初始化判断题答案数组
      this.judgeAnswer = new Array(this.topicCount[2]).fill(undefined);
    },
    
    /**
     * 显示当前题目
     */
    showQuestion() {
      const currentTopic = this.getCurrentTopic();
      if (!currentTopic) return;
      
      this.showQuestion = currentTopic.question;
      this.number = this.getQuestionNumber();
      
      // 根据题目类型设置显示内容
      if (this.currentType === 1) {
        // 选择题
        this.showAnswer = {
          answerA: currentTopic.answerA,
          answerB: currentTopic.answerB,
          answerC: currentTopic.answerC,
          answerD: currentTopic.answerD
        };
        this.reduceAnswer = {
          rightAnswer: currentTopic.rightAnswer,
          analysis: currentTopic.analysis
        };
      } else if (this.currentType === 2) {
        // 填空题
        this.part = currentTopic.answer.split('|'); // 按|分割多个空
      } else if (this.currentType === 3) {
        // 判断题
        // 判断题不需要额外设置
      }
    },
    
    /**
     * 获取当前题目
     */
    getCurrentTopic() {
      return this.topic[this.currentType][this.index];
    },
    
    /**
     * 获取题目编号
     */
    getQuestionNumber() {
      let number = this.index + 1;
      if (this.currentType === 2) {
        number += this.topicCount[0];
      } else if (this.currentType === 3) {
        number += this.topicCount[0] + this.topicCount[1];
      }
      return number;
    },
    
    // ==================== 答题操作方法 ====================
    
    /**
     * 切换到选择题
     */
    change(index) {
      this.currentType = 1;
      this.index = index;
      this.title = '选择题';
      this.showQuestion();
    },
    
    /**
     * 切换到填空题
     */
    fill(index) {
      this.currentType = 2;
      this.index = index;
      this.title = '填空题';
      this.showQuestion();
    },
    
    /**
     * 切换到判断题
     */
    judge(index) {
      this.currentType = 3;
      this.index = index;
      this.title = '判断题';
      this.showQuestion();
    },
    
    /**
     * 选择题答案变化处理
     */
    getChangeLabel(value) {
      this.radio[this.index] = value;
      this.topic[1][this.index].isClick = true;
    },
    
    /**
     * 填空题答案变化处理
     */
    fillBG() {
      // 检查填空题是否已填写
      const hasAnswer = this.fillAnswer[this.index].some(answer => answer.trim() !== '');
      this.topic[2][this.index].isClick = hasAnswer;
    },
    
    /**
     * 判断题答案变化处理
     */
    getJudgeLabel(value) {
      this.judgeAnswer[this.index] = value;
      this.topic[3][this.index].isClick = true;
    },
    
    /**
     * 上一题
     */
    previous() {
      if (this.index > 0) {
        this.index--;
        this.showQuestion();
      }
    },
    
    /**
     * 下一题
     */
    next() {
      const totalQuestions = this.topicCount[0] + this.topicCount[1] + this.topicCount[2];
      if (this.index < totalQuestions - 1) {
        this.index++;
        this.showQuestion();
      }
    },
    
    /**
     * 标记题目
     */
    markQuestion() {
      const currentTopic = this.getCurrentTopic();
      if (currentTopic) {
        currentTopic.isMark = !currentTopic.isMark;
      }
    },
    
    /**
     * 提交答案
     */
    submitAnswer() {
      // 这里可以添加答案提交逻辑
      this.$message.success('答案已保存');
    },
    
    // ==================== 倒计时相关方法 ====================
    
    /**
     * 启动倒计时
     */
    startTimer() {
      this.time = this.examData.duration || 120; // 默认120分钟
      
      this.timer = setInterval(() => {
        if (this.time > 0) {
          this.time--;
        } else {
          // 时间到，自动提交
          this.finishExam();
        }
      }, 60000); // 每分钟更新一次
    },
    
    // ==================== 考试结束相关方法 ====================
    
    /**
     * 结束考试
     */
    finishExam() {
      this.$confirm('确定要结束考试吗？', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        // 停止摄像头
        this.stopCamera();
        
        // 停止倒计时
        if (this.timer) {
          clearInterval(this.timer);
        }
        
        // 提交考试答案
        this.submitExam();
      });
    },
    
    /**
     * 提交考试答案到后端
     */
    submitExam() {
      const examData = {
        examId: this.$route.query.examId,
        studentId: this.userInfo.id,
        answers: {
          radio: this.radio,
          fillAnswer: this.fillAnswer,
          judgeAnswer: this.judgeAnswer
        }
      };
      
      this.$axios({
        url: '/api/exam/submitExam',
        method: 'post',
        data: examData
      }).then(res => {
        if (res.data.code === 200) {
          this.$message.success('考试提交成功！');
          // 跳转到成绩页面
          this.$router.push('/student/studentScore');
        } else {
          this.$message.error('考试提交失败！');
        }
      });
    }
  },
  
  // 生命周期钩子
  mounted() {
    // 获取用户信息
    this.userInfo.name = this.$cookies.get('cname');
    this.userInfo.id = this.$cookies.get('cid');
    
    // 获取考试信息
    this.getExamInfo();
    
    // 显示第一题
    this.showQuestion();
  },
  
  beforeDestroy() {
    // 组件销毁前清理资源
    this.stopCamera();
    if (this.timer) {
      clearInterval(this.timer);
    }
  }
}
</script>

<style lang="less" scoped>
/* 摄像头监控样式 */
.camera-container {
  position: fixed;
  top: 20px;
  right: 20px;
  width: 200px;
  height: 150px;
  background: #000;
  border-radius: 8px;
  overflow: hidden;
  z-index: 1000;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

#video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.camera-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.camera-status {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 8px;
  font-size: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.status-ok {
  color: #67c23a;
}

.status-warning {
  color: #e6a23c;
}

.camera-restart-btn {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  padding: 4px;
}

.camera-placeholder-content {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  color: white;
  background: rgba(0, 0, 0, 0.8);
}

.camera-init-btn {
  margin-top: 10px;
  padding: 8px 16px;
  background: #409eff;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

.camera-init-btn:disabled {
  background: #909399;
  cursor: not-allowed;
}

/* 考试界面整体样式 */
#answer {
  height: 100vh;
  background: #f5f5f5;
  display: flex;
  flex-direction: column;
}

/* 顶部信息栏样式 */
.top {
  background: white;
  border-bottom: 1px solid #e4e7ed;
  padding: 10px 20px;
}

.top .item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  list-style: none;
}

.top .item li {
  display: flex;
  align-items: center;
}

.top .item .msg {
  position: absolute;
  top: 100%;
  right: 0;
  background: white;
  border: 1px solid #e4e7ed;
  border-radius: 4px;
  padding: 10px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* 主要内容区域样式 */
.flexarea {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* 左侧题目导航样式 */
.left {
  width: 300px;
  background: white;
  border-right: 1px solid #e4e7ed;
  display: flex;
  flex-direction: column;
}

.l-top {
  padding: 20px;
  border-bottom: 1px solid #e4e7ed;
  display: flex;
  justify-content: space-around;
}

.l-top li {
  display: flex;
  flex-direction: column;
  align-items: center;
  list-style: none;
}

.l-top li a {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  margin-bottom: 5px;
}

.l-top li:nth-child(1) a {
  background: #409eff;
}

.l-top li:nth-child(2) a {
  background: #f56c6c;
}

.l-top li:nth-child(3) a {
  background: #67c23a;
}

.l-top li:nth-child(4) a {
  background: #e6a23c;
}

.l-bottom {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
}

.l-bottom .item {
  margin-bottom: 20px;
}

.l-bottom .item p {
  font-weight: bold;
  margin-bottom: 10px;
}

.l-bottom .item ul {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.l-bottom .item li {
  list-style: none;
}

.l-bottom .item a {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: 1px solid #dcdfe6;
  border-radius: 4px;
  text-decoration: none;
  color: #606266;
  position: relative;
}

.l-bottom .item a.border {
  border-color: #409eff;
  color: #409eff;
}

.l-bottom .item a.bg {
  background: #67c23a;
  color: white;
  border-color: #67c23a;
}

.l-bottom .item a .mark {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 8px;
  height: 8px;
  background: #e6a23c;
  border-radius: 50%;
}

.final {
  text-align: center;
  padding: 15px;
  background: #f56c6c;
  color: white;
  border-radius: 4px;
  cursor: pointer;
  margin-top: 20px;
}

/* 右侧答题区域样式 */
.right {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: white;
}

.right .title {
  padding: 20px;
  border-bottom: 1px solid #e4e7ed;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.right .content {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
}

.right .topic {
  font-size: 16px;
  line-height: 1.6;
  margin-bottom: 20px;
}

.right .topic .number {
  color: #409eff;
  font-weight: bold;
  margin-right: 10px;
}

.right .fill {
  margin-bottom: 20px;
}

.right .fill .el-input {
  margin-bottom: 10px;
}

.right .analysis {
  margin-top: 20px;
  padding: 15px;
  background: #f8f9fa;
  border-radius: 4px;
}

.right .analysis ul {
  list-style: none;
  padding: 0;
}

.right .analysis li {
  margin-bottom: 10px;
}

.right .analysis .right {
  color: #67c23a;
  font-weight: bold;
}

/* 底部操作按钮样式 */
.footer {
  padding: 20px;
  border-top: 1px solid #e4e7ed;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* 过渡动画样式 */
.slider-fade-enter-active,
.slider-fade-leave-active {
  transition: all 0.3s ease;
}

.slider-fade-enter,
.slider-fade-leave-to {
  transform: translateX(-100%);
  opacity: 0;
}
</style> 